An optimizing compiler is a compiler configured to optimize attributes of an executable computer program code to achieve a particular goal. One optimization technique commonly implemented is to optimize a computer program to minimize the amount of time it takes to execute the computer program during operation. Another optimization technique commonly implemented is to minimize the amount of memory utilized by the computer program during operation.
There are several levels of optimization that a user can specify when compiling a computer program. For example, the GNU Compiler Collection (GCC) specifies a number optimization levels. With level 0 (o0), no optimization is performed. With level 1 (o1) optimization, most common forms of optimization that do not require any speed-space tradeoffs are implemented. Accordingly, the executable typically does not increase in size. With level 2 (o2) optimization, in addition to the optimizations used in level 1, further optimizations are implemented, including instruction scheduling. Again, the executable typically does not increase in size when level 2 optimization is used. With level 3 (o3) optimization, in addition to the optimizations used in level 1 and level 2, more expensive optimizations (in terms of memory usage), such as function inlining, are used. Level 3 optimization may increase the speed of the resulting executable, but also may increase its size. Under some circumstances, for example where these optimizations are not favorable, level 3 optimization may actually cause a program to execute slower. Other optimizations, such as loop-unrolling and size reduction optimizations sometimes also are used.